<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <h1>注册页</h1>
    <form action="#">
        <input type="text" class="username">
        <input type="password" class="password">
        <input type="password" class="rpwd">
        <input type="text" class="nickname">
        <button>注册</button>
    </form>
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>

    <script>
         const form = document.querySelector('form');
         const username = document.querySelector('.username');
         const password = document.querySelector('.password');
         const rpwd = document.querySelector('.rpwd');
         const nickname = document.querySelector('.nickname');

         form.addEventListener('submit',async e=>{
            e.preventDefault();


            const info = {
                username: username.value,
                password:password.value,
                rpassword:rpwd.value,
                nickname:nickname.value
            }
            const res = await axios.put('/api/users/register',info);

            console.log(res.data);
         });


    </script>
</body>
</html>